<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>AdminLTE 2 | Dashboard</title>
        <!-- Tell the browser to be responsive to screen width -->
        <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
        <!-- Bootstrap 3.3.6 -->
        <link rel="stylesheet" href="/public/ui/framework/bootstrap-3.3.7-dist/css/bootstrap.min.css">
        <!-- Font Awesome -->
        <link rel="stylesheet" href="/Public/UI/Fonts/Font-Awesome-4.7.0/css/font-awesome.min.css">
        <!-- Ionicons -->
        <link rel="stylesheet" href="/Public/UI/Fonts/ionicons-2.0.1/css/ionicons.min.css">
        <!-- TreeGrid 0.3.0 -->
        <link rel="stylesheet" href="/Public/UI/Plugins/TreeGridLib/jquery-treegrid-0.3.0/css/jquery.treegrid.css">
        <!-- Theme style -->
        <link rel="stylesheet" href="/Public/ui/adminlte/css/AdminLTE.min.css">
        <!-- AdminLTE Skins. Choose a skin from the css/skins
             folder instead of downloading all of them to reduce the load. -->
        <link rel="stylesheet" href="/Public/ui/adminlte/css/skins/_all-skins.min.css">
    </head>
    <body>
        <!-- Content Wrapper. Contains page content -->
        <div class="content-wrapper" style="margin:0;">
            <!-- Content Header (Page header) -->
            <section class="content-header">
                <h1>
                    栏目管理
                    <small>advanced tables</small>
                </h1>
                <ol class="breadcrumb">
                    <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
                    <li><a href="#">内容</a></li>
                    <li class="active">栏目管理</li>
                </ol>
            </section>

            <!-- Main content -->
            <section class="content">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="box">
                            <div class="box-header">
                                <div class="row">
                                    <div class="col-md-5">
                                        <button type="button" class="btn btn-default navbar-btn xsui-btn-add-dialog" data-url="edit_member.html" title="新增会员">新增</button>
                                        <button type="button" class="btn btn-danger navbar-btn xsui-btn-multi-delete" data-url="delete.html?id=varkey">批量删除</button>
                                        <button type="button" class="btn btn-success navbar-btn xsui-btn-refresh">刷新</button>
                                    </div>
                                    <div class="col-md-7">
                                        <form class="navbar-form navbar-right">
                                            <div class="form-group">
                                                <input type="text" name="word" class="form-control" placeholder="关键词..." title="用户名、姓名、手机号码、电子邮件">
                                            </div>
                                            <button type="submit" class="btn btn-default">搜索</button>
                                        </form>
                                    </div>
                                </div>
                            </div>
                            <!-- /.box-header -->
                            <div class="box-body">
                                <table class="xsui-treegrid table table-condensed table-bordered table-striped table-hover">
                                    <thead>
                                        <tr>
                                            <th><input type="checkbox" class="xsui-btn-checking-all" /></th>
                                            <th>#</th>
                                            <th>名称</th>
                                            <th>代码</th>
                                            <th>排序</th>
                                            <th>状态</th>
                                            <th>创建时间</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php if(is_array($tree)): foreach($tree as $key=>$vo): ?><tr class="treegrid-1" data-key="<?php echo ($vo["id"]); ?>">
                                            <td><input type="checkbox" value="0" /></td>
                                            <td title="<?php echo ($vo["id"]); ?>"></td>
                                            <td title="<?php echo ($vo["id"]); ?>|<?php echo ($vo["title"]); ?>"><a href="<?php echo U('edit','id='.$vo['id']);?>" class="xsui-lnk-edit-dialog" data-id="<?php echo ($vo["id"]); ?>" title="编辑 <?php echo ($vo["title"]); ?>"><?php echo xsfn_msubstr($vo['title'],0,30);?></a>
                                            
                <?php switch($vo['type_name']): case "page": ?><a href="<?php echo U('content_edit','id='.$vo['id']);?>" class="xsui-a xsui-lnk-edit-dialog" data-id="<?php echo ($vo["id"]); ?>" title="编辑内容--<?php echo ($vo["title"]); ?>"><i class="fa fa-file-text-o"></i></a><?php break;?>
        <?php case "document-list": ?><a href="<?php echo U('Documents/document_edit','category_id='.$vo['id']);?>" class="xsui-a" data-id="<?php echo ($vo["id"]); ?>" title="新增文章--<?php echo ($vo["title"]); ?>">添加文章</a><a href="<?php echo U('Documents/document_list','category_id='.$vo['id']);?>" class="xsui-icon-only xsui-lnk-tab" data-id="<?php echo ($vo["id"]); ?>" title="管理文章--<?php echo ($vo["title"]); ?>"><i class="fa fa-folder-open-o"></i></a><?php break;?>
        <?php case "url": ?><a href="<?php echo U('link_edit','id='.$vo['id']);?>" class="xsui-a xsui-lnk-edit-dialog" data-id="<?php echo ($vo["id"]); ?>" title="编辑链接--<?php echo ($vo["title"]); ?>"><i class="fa fa-link"></i></a><?php break;?>
        <?php case "file-list": ?><a href="<?php echo U('File/file_edit','category_id='.$vo['id']);?>" class="xsui-a xsui-lnk-edit-dialog" data-id="<?php echo ($vo["id"]); ?>" title="添加文件--<?php echo ($vo["title"]); ?>">添加文件</a><a href="<?php echo U('File/file_list','category_id='.$vo['id']);?>" class="xsui-icon-only xsui-lnk-tab" data-id="<?php echo ($vo["id"]); ?>" title="管理文件--<?php echo ($vo["title"]); ?>"><i class="fa fa-folder-open-o"></i></a><?php break; endswitch;?>
                                            </td>
                                            <td><?php echo ($vo["code"]); ?></td>
                                            <td class="xsui-cell-sort"><input type="text" value="<?php echo ($vo["sort"]); ?>" size="3" data-value="<?php echo ($vo["sort"]); ?>" data-url="<?php echo U('changeSort','id='.$vo['id'].'&sort=varsort');?>" title="更改后,鼠标点击页面任意位置即可自动生效" /></td>
                                            <td class="xsui-cell-status"><a href="<?php echo U('changeStatus','id='.$vo['id'].'&status=varstatus');?>" data-value="<?php echo ($vo["status"]); ?>" title="点击隐藏" class="xsui-success"><i class="fa fa-check fa-fw"></i></a></td>
                                            <td><?php echo ($vo["create_time"]); ?></td>
                                            <td class="xsui-action-td">
                                                <div class="btn-group">
                                                    <a class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" href="#">
                                                        操作
                                                        <span class="caret"></span>
                                                    </a>
                                                    <ul class="dropdown-menu pull-right" style="min-width: 60px">
                                                        <li><a href="<?php echo U('edit','id='.$vo['id']);?>" class="xsui-btn-edit-dialog" title="编辑 <?php echo ($vo['title']); ?>"><span class="glyphicon glyphicon-edit"></span>编辑</a></li>
                                                        <li><a href="<?php echo U('delete','id='.$vo['id']);?>" class="xsui-btn-delete" title="删除 <?php echo ($vo['title']); ?>"><span class="glyphicon glyphicon-remove"></span>删除</a></li>
                                                    </ul>
                                                </div>
                                            </td>
                                        </tr>
                                        <?php if(is_array($vo['children'])): foreach($vo['children'] as $key=>$vo2): ?><tr class="treegrid-2  treegrid-parent-1" data-key="<?php echo ($vo2["id"]); ?>">
                                            <td><input type="checkbox" value="0" /></td>
                                            <td title="<?php echo ($vo["id"]); ?>"></td>
                                            <td title="<?php echo ($vo2["id"]); ?>|<?php echo ($vo2["title"]); ?>"><a href="<?php echo U('edit','id='.$vo2['id']);?>" class="xsui-lnk-edit-dialog" data-id="<?php echo ($vo2["id"]); ?>" title="编辑 <?php echo ($vo2["title"]); ?>"><?php echo xsfn_msubstr($vo2['title'],0,30);?></a></td>
                                            <td><?php echo ($vo2["code"]); ?></td>
                                            <td class="xsui-cell-sort"><input type="text" value="<?php echo ($vo2["sort"]); ?>" size="3" data-value="<?php echo ($vo2["sort"]); ?>" data-url="<?php echo U('changeSort','id='.$vo2['id'].'&sort=varsort');?>" title="更改后,鼠标点击页面任意位置即可自动生效" /></td>
                                            <td class="xsui-cell-status"><a href="<?php echo U('changeStatus','id='.$vo2['id'].'&status=varstatus');?>" data-value="<?php echo ($vo2["status"]); ?>" title="点击隐藏" class="xsui-success"><i class="fa fa-check fa-fw"></i></a></td>
                                            <td><?php echo ($vo2["create_time"]); ?></td>
                                            <td class="xsui-action-td">
                                                <div class="btn-group">
                                                    <a class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown" href="#">
                                                        操作
                                                        <span class="caret"></span>
                                                    </a>
                                                    <ul class="dropdown-menu pull-right" style="min-width: 60px">
                                                        <li><a href="<?php echo U('edit','id='.$vo2['id']);?>" class="xsui-btn-edit-dialog" title="编辑 <?php echo ($vo2['title']); ?>"><span class="glyphicon glyphicon-edit"></span>编辑</a></li>
                                                        <li><a href="<?php echo U('delete','id='.$vo2['id']);?>" class="xsui-btn-delete" title="删除 <?php echo ($vo2['title']); ?>"><span class="glyphicon glyphicon-remove"></span>删除</a></li>
                                                    </ul>
                                                </div>
                                            </td>
                                        </tr><?php endforeach; endif; endforeach; endif; ?>
                                    </tbody>
                                </table>
                            </div>
                            <!-- /.box-body -->
                        </div>
                        <!-- /.box -->
                    </div>
                    <!-- /.col -->
                </div>
                <!-- /.row -->
            </section>
            <!-- /.content -->
        </div>
        <!-- /.content-wrapper -->

        <!-- jQuery 2.2.3 -->
        <script src="/Public/UI/Plugins/jQuery/jquery-2.2.3.min.js"></script>
        <!-- Bootstrap 3.3.6 -->
        <script src="/public/ui/framework/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
        <!-- DataTables -->
        <script src="/Public/UI/Plugins/TreeGridLib/jquery-treegrid-0.3.0/js/jquery.treegrid.min.js"></script>
        <script src="/Public/UI/Plugins/TreeGridLib/jquery-treegrid-0.3.0/js/jquery.treegrid.bootstrap3.js"></script>
        <!-- Layer 3.0.1 -->
        <script src="/Public/UI/Plugins/DialogLib/layer-v3.0.1/layer.js"></script>

        <!-- page script -->
        <script type="text/javascript">
            $(function () {
                xsTreeGrid.init_default_grid();
                xsTreeGrid.init_checkbox_column();
                xsTreeGrid.init_index_column();
                xsTreeGrid.init_operate_button();
            });
            var xsTreeGrid = {};
            xsTreeGrid.options = {
            }
            xsTreeGrid.init_default_grid = function (options) {
                // 2017-2-13
                var defaults = xsTreeGrid.options;
                if (undefined !== options) {
                    $.extend(defaults, options);
                }
                $('.xsui-treegrid').treegrid({treeColumn: 2});
            };
            xsTreeGrid.init_checkbox_column = function () {
                // 全选和取消全选 2017-2-21
                $('.xsui-btn-checking-all').click(function () {
                    $('.xsui-datagrid tbody td :checkbox').prop('checked', $(this).prop('checked'));
                })
            }
            xsTreeGrid.init_index_column = function () {
                // 表格序号列
                $('.xsui-datagrid tbody tr').each(function (i) {
                    $(this).children().eq(1).text(i + 1);
                })
            }
            xsTreeGrid.init_operate_button = function () {
                // 2017-2-21
                $('.xsui-btn-delete').click(function () {
                    if (!confirm('您确定要删除该记录吗?')) {
                        return false;
                    }
                    var url = $(this).attr('href');
                    $.get(url, {}, function (data) {
                        if (data.success) {
                            location.reload();
                        } else {
                            layer.alert(data.info, {icon: 5, offset: [160, 0]});
                        }
                    })
                    return false;
                })
                // 批量删除 2017-2-13
                $('.xsui-btn-multi-delete').click(function () {
                    var url = $btn.attr('href') ? $btn.attr('href') : $btn.data('url');
                    if (!url) {
                        alert('URL无效!');
                        return false;
                    }
                    var ids = '';
                    var n = 0;
                    $('#example1 tbody tr :checkbox:checked').each(function () {
                        if (ids) {
                            ids += ',';
                        }
                        ids += $(this).val();
                        n++;
                    });
                    if (n < 1) {
                        alert('没有选中任何行!');
                        return false;
                    }
                    if (!confirm('您确定要删除选中的 ' + n + ' 条记录吗?')) {
                        return false;
                    }
                    $.get(url, {}, function (data) {
                        if (data.status) {
                            location.reload();
                        } else {
                            layer.alert(data.info, {icon: 5, offset: [160, 0]});
                        }
                    })
                    return false;
                })
                // 新增 2017-2-14
                $('.xsui-btn-add-dialog, .xsui-btn-edit-dialog').click(function () {
                    var $btn = $(this);
                    var url = $btn.attr('href') ? $btn.attr('href') : $btn.data('url');
                    if (!url) {
                        alert('URL无效!');
                        return false;
                    }
                    var title = $btn.attr('title') ? $btn.attr('title') : $btn.text();
                    var options = {width: 768, height: 520};
                    var soption = $btn.data('xsuiOption'); // 控件的[data-xsui-option]属性自定义选项：<a data-xsui-option="{'key':'value'}" />
                    if (soption) {
                        options = xsfn_extend_options(options, soption);
                    }
                    //iframe窗
                    layer.open({
                        type: 2,
                        title: title,
                        closeBtn: 1, //不显示关闭按钮
                        shade: [0],
                        //area: [options.width + 'px', options.height + 'px'],
                        area: ['50vw', '50vh'],
                        //offset: 'rb', //右下角弹出
                        //time: 2000, //2秒后自动关闭
                        maxmin: true, //开启最大化最小化按钮
                        offset: [160, 0],
                        anim: 2,
                        content: [url, 'no'], //iframe的url，no代表不显示滚动条
                    });
                    return false;
                })

                // 状态单元格切换开关控制 2016-1-18 SoChishun Added.
                // 如：<td class="xsui-cell-status"><a href="AddonU('changeStatus','id='.$vo['id'].'&status=varstatus')" title="点击隐藏" data-value="$vo.status" class="xsui-success"><i class="fa fa-check fa-fw"></i></a></td>
                if ('undefined' !== typeof ($.fn.togglelink)) {
                    $('td.xsui-cell-status a').togglelink();
                }
                // 动态更改排序 2015-10-24 SoChishun Added.
                $('td.xsui-cell-sort input').blur(function () {
                    var $input = $(this);
                    xsGrid.xsfn_changeSort($input);
                })
            }
            /**
             * 控制选项合并
             * <br />主要用于按钮点击事件中，合并事件方法中的默认选项与用户写在按钮中的[data-xsui-option]属性的字符串选项
             * @param {json|object} options
             * @param {string} soption
             * @returns {Object}
             * @version 1.0 2016-12-29
             * @example extend_options({a:'a1'},"{'a':'a2'}");
             */
            xsTreeGrid.xsfn_extend_options = function (options, soption) {
                if (!soption || soption.indexOf(':') < 0) {
                    return options;
                }
                if (soption.indexOf('}') < 0) {
                    soption = '{' + soption + '}'
                }
                try {
                    var option = new Function("return " + soption)();
                    if (option) {
                        options = $.extend(options, option);
                    }
                } catch (e) {
                    console.log(e);
                }
                return options;
            }
        </script>
    </body>
</html>